/**
 *
 *
 *
 *
 *
 */

package org.sxp.modules.sys.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.sxp.common.annotation.SysLog;
import org.sxp.common.utils.PageInfo;
import org.sxp.common.utils.PageResult;
import org.sxp.common.utils.Query;
import org.sxp.common.web.WrapperResponse;
import org.sxp.modules.sys.entity.SysLogEntity;
import org.sxp.modules.sys.service.SysLogService;

import java.util.List;


/**
 * 系统日志
 *
 *
 */
@RestController
@RequestMapping("/sys/log")
@Api(description="Log", tags = "系统日志")
@SysLog(modules = "sys", value = "系统日志")
public class SysLogController extends AbstractController{
	@Autowired
	private SysLogService sysLogService;

	/**
	 * 列表
	 */
	@ApiImplicitParams({
			@ApiImplicitParam(name="pageNum", value = "当前页码", dataType="int", paramType = "header"),
			@ApiImplicitParam(name="pageSize",value="每页条目",dataType="int", paramType = "header"),
			@ApiImplicitParam(name="orderField",value="排序字段",dataType="string", paramType = "header"),
			@ApiImplicitParam(name="orderType",value="排序类型",dataType="string", paramType = "header", example = "asc或者desc")
	})
	@RequestMapping(value = "/list",method = {RequestMethod.POST,RequestMethod.GET})
	@ApiOperation(value = "查询列表")
	@RequiresPermissions("sys:log:list")
	public WrapperResponse<List<SysLogEntity>> list(SysLogEntity params) throws Exception{
		//请求头获取分页参数
		PageInfo pageInfo = buildPageInfo();
		IPage<SysLogEntity> page = sysLogService.page(
				new Query<SysLogEntity>().getPage(pageInfo)
				,new LambdaQueryWrapper<SysLogEntity>());

		return (WrapperResponse)WrapperResponse.success(new PageResult(page));
	}
	
}
